<?php
session_start();
require_once("connection.php");
require_once("../functions_shared.php");
$data = $_POST['checklist'];



$response = array();
$response["error"] = "hereee";

if(isset($_SESSION['user']))
{
	//$response["error"] .= "online";
	register_user($response["error"]);
	$response['session'] = "true";
}
else {
	$response['session'] = "false";
}


// checking for other users
if($data!="")
{
	$arr = explode(";",$data);
	foreach($arr as $user_id)
	{
		if($user_id != "") // to filter blank requests
		{	
			$temp = explode("_",$user_id);
			if($temp[0] == "user"){
				$id = $temp[1];		
				if($temp[2] == "gen")
				$response[''.$user_id.''] = is_user_online($id);
				else if($temp[2] == "circle")
				$response[''.$user_id.''] = is_user_online($id,"reduced");								
				else if($temp[2] == "invite")								
				$response[''.$user_id.''] = is_user_online($id,"invite_".$temp[3]."");
			}
			else if($temp[0] == "unread"){
				$id = $temp[1];		
				$response[''.$user_id.''] = user_unread($id);
			}
			else if($temp[0] == "time"){
				$stream_type = $temp[1];
				$stream_ele_id = $temp[2];
				$response[''.$user_id.''] = post_time($stream_type, $stream_ele_id);
			}
			
		}
	}
}
echo json_encode($response);
?>